package com.luu.game.dao.impl;

import com.luu.game.dao.ElfDao;
import com.luu.game.data.dto.ElfDTO;
import com.luu.game.data.dto.ElfRegionDTO;
import com.luu.game.data.dto.ElfSkillDTO;
import com.luu.game.data.entity.ElfEntity;
import com.luu.game.mapper.ElfMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class ElfDaoImpl implements ElfDao {

    @Autowired
    private ElfMapper elfMapper;

    @Override
    public ElfDTO findByIdAndSkId(Integer userElfId, Integer skId) {
        return null;
    }

    @Override
    public List<ElfRegionDTO> findElfByRegionId(Integer regionId) {
        return elfMapper.findElfByRegionId(regionId);
    }

    @Override
    public ElfDTO findById(Integer id) {
        final ElfDTO result = new ElfDTO();
        final ElfEntity elfEntity = elfMapper.selectById(id);
        BeanUtils.copyProperties(elfEntity,result);
        return result;
    }

    @Override
    public List<ElfSkillDTO> findSkillByElfId(Integer id) {
        return elfMapper.findSkillByElfId(id);
    }
}
